home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3 / Xext / DBE.z / DBE
Encoding:
Text File  |  2001-04-17  |  21.2 KB  |  397 lines

  1.  
  2.  
  3.  
  4.      DDDDBBBBEEEE((((3333XXXX11111111))))          XXXX VVVVeeeerrrrssssiiiioooonnnn 11111111 ((((RRRReeeelllleeeeaaaasssseeee 6666....3333))))           DDDDBBBBEEEE((((3333XXXX11111111))))
  5.  
  6.  
  7.  
  8.      NNNNAAAAMMMMEEEE
  9.           DBE - Double Buffer Extension
  10.  
  11.      SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.           The Double Buffer Extension (DBE) provides a standard way to
  13.           utilize double-buffering within the framework of the X
  14.           Window System.  Double-buffering uses two buffers, called
  15.           front and back, which hold images.  The front buffer is
  16.           visible to the user; the back buffer is not.  Successive
  17.           frames of an animation are rendered into the back buffer
  18.           while the previously rendered frame is displayed in the
  19.           front buffer.  When a new frame is ready, the back and front
  20.           buffers swap roles, making the new frame visible.  Ideally,
  21.           this exchange appears to happen instantaneously to the user,
  22.           with no visual artifacts.  Thus, only completely rendered
  23.           images are presented to the user, and remain visible during
  24.           the entire time it takes to render a new frame.  The result
  25.           is a flicker-free animation.
  26.  
  27.      DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  28.           CCCCoooonnnncccceeeeppppttttssss
  29.                Normal windows are created using XXXXCCCCrrrreeeeaaaatttteeeeWWWWiiiinnnnddddoooowwww(((()))) or
  30.                XXXXCCCCrrrreeeeaaaatttteeeeSSSSiiiimmmmpppplllleeeeWWWWiiiinnnnddddoooowwww(((()))),,,, which allocate a set of window
  31.                attributes and, for InputOutput windows, a front
  32.                buffer, into which an image can be drawn.  The contents
  33.                of this buffer will be displayed when the window is
  34.                visible.
  35.  
  36.                This extension enables applications to use double-
  37.                buffering with a window.  This involves creating a
  38.                second buffer, called a back buffer, and associating
  39.                one or more back buffer names (_X_I_D_s) with the window,
  40.                for use when referring to (i.e., drawing to or reading
  41.                from) the window's back buffer.  The back buffer name
  42.                is a drawable of type _X_d_b_e_B_a_c_k_B_u_f_f_e_r.
  43.  
  44.                DBE provides a relative double-buffering model.  One
  45.                XID, the window, always refers to the front buffer.
  46.                One or more other XIDs, the back buffer names, always
  47.                refer to the back buffer.  After a buffer swap, the
  48.                window continues to refer to the (new) front buffer,
  49.                and the back buffer name continues to refer to the
  50.                (new) back buffer.  Thus, applications and toolkits
  51.                that want to just render to the back buffer always use
  52.                the back buffer name for all drawing requests to the
  53.                window.  Portions of an application that want to render
  54.                to the front buffer always use the window XID for all
  55.                drawing requests to the window.
  56.  
  57.                Multiple clients and toolkits can all use double-
  58.                buffering on the same window.  DBE does not provide a
  59.                request for querying whether a window has double-
  60.  
  61.  
  62.  
  63.      Page 1                                           (printed 4/6/01)
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.      DDDDBBBBEEEE((((3333XXXX11111111))))          XXXX VVVVeeeerrrrssssiiiioooonnnn 11111111 ((((RRRReeeelllleeeeaaaasssseeee 6666....3333))))           DDDDBBBBEEEE((((3333XXXX11111111))))
  71.  
  72.  
  73.  
  74.                buffering support, and if so, what the back buffer name
  75.                is.  Given the asynchronous nature of the X Window
  76.                System, this would cause race conditions.  Instead, DBE
  77.                allows multiple back buffer names to exist for the same
  78.                window; they all refer to the same physical back
  79.                buffer.  The first time a back buffer name is allocated
  80.                for a window, the window becomes double-buffered and
  81.                the back buffer name is associated with the window.
  82.                Subsequently, the window already is a double-buffered
  83.                window, and nothing about the window changes when a new
  84.                back buffer name is allocated, except that the new back
  85.                buffer name is associated with the window.  The window
  86.                remains double-buffered until either the window is
  87.                destroyed, or until all of the back buffer names for
  88.                the window are deallocated.
  89.  
  90.                In general, both the front and back buffers are treated
  91.                the same.  In particular, here are some important
  92.                characteristics:
  93.  
  94.                     Only one buffer per window can be visible at a
  95.                     time (the front buffer).
  96.  
  97.                     Both buffers associated with a window have the
  98.                     same visual type, depth, width, height, and shape
  99.                     as the window.
  100.  
  101.                     Both buffers associated with a window are
  102.                     "visible" (or "obscured") in the same way.  When
  103.                     an Expose event is generated for a window, this
  104.                     event is considered to apply to both buffers
  105.                     equally.  When a double-buffered window is
  106.                     exposed, both buffers are tiled with the window
  107.                     background.  Even though the back buffer is not
  108.                     visible, terms such as obscure apply to the back
  109.                     buffer as well as to the front buffer.
  110.  
  111.                     It is acceptable at any time to pass an
  112.                     _X_d_b_e_B_a_c_k_B_u_f_f_e_r in any function that expects a
  113.                     drawable.  This enables an application to draw
  114.                     directly into _X_d_b_e_B_a_c_k_B_u_f_f_e_r in the same fashion
  115.                     as it would draw into any other drawable.
  116.  
  117.                     It is an error (Window) to pass an _X_d_b_e_B_a_c_k_B_u_f_f_e_r
  118.                     in a function that expects a Window.
  119.  
  120.                     An _X_d_b_e_B_a_c_k_B_u_f_f_e_r will never be sent in a reply,
  121.                     event, or error where a Window is specified.
  122.  
  123.                     If backing-store and save-under applies to a
  124.                     double-buffered window, it applies to both buffers
  125.                     equally.
  126.  
  127.  
  128.  
  129.      Page 2                                           (printed 4/6/01)
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.      DDDDBBBBEEEE((((3333XXXX11111111))))          XXXX VVVVeeeerrrrssssiiiioooonnnn 11111111 ((((RRRReeeelllleeeeaaaasssseeee 6666....3333))))           DDDDBBBBEEEE((((3333XXXX11111111))))
  137.  
  138.  
  139.  
  140.                     If the XXXXCCCClllleeeeaaaarrrrAAAArrrreeeeaaaa(((()))) or XXXXCCCClllleeeeaaaarrrrWWWWiiiinnnnddddoooowwww(((()))) function is
  141.                     executed on a double-buffered window, the same
  142.                     area in both the front and back buffers is
  143.                     cleared.
  144.  
  145.                The effect of passing a window to a function that
  146.                accepts a drawable is unchanged by this extension.  The
  147.                window and front buffer are synonomous with each other.
  148.                This includes obeying the XXXXGGGGeeeettttIIIImmmmaaaaggggeeee(((()))) and
  149.                XXXXGGGGeeeettttSSSSuuuubbbbIIIImmmmaaaaggggeeee(((()))) semantics and the subwindow-mode
  150.                semantics if a graphics context is involved.
  151.                Regardless of whether the window was explicitly passed
  152.                in an XXXXGGGGeeeettttIIIImmmmaaaaggggeeee(((()))) or XXXXGGGGeeeettttSSSSuuuubbbbIIIImmmmaaaaggggeeee(((()))) call, or implicitly
  153.                referenced (i.e., one of the window's ancestors was
  154.                passed in the function), the front (i.e. visible)
  155.                buffer is always referenced.  Thus, DBE-naive screen
  156.                dump clients will always get the front buffer.
  157.                XXXXGGGGeeeettttIIIImmmmaaaaggggeeee(((()))) and XXXXGGGGeeeettttSSSSuuuubbbbIIIImmmmaaaaggggeeee(((()))) on a back buffer return
  158.                undefined image contents for any obscured regions of
  159.                the back buffer that fall within the image.
  160.  
  161.                Drawing to a back buffer always uses the clip region
  162.                that would be used to draw to the front buffer with a
  163.                GC subwindow-mode of ClipByChildren.  If an ancestor of
  164.                a double-buffered window is drawn to with a GC having a
  165.                subwindow-mode of IncludeInferiors, the effect on the
  166.                double-buffered window's back buffer depends on the
  167.                depth of the double-buffered window and the ancestor.
  168.                If the depths are the same, the contents of the back
  169.                buffer of the double-buffered window are not changed.
  170.                If the depths are different, the contents of the back
  171.                buffer of the double-buffered window are undefined for
  172.                the pixels that the IncludeInferiors drawing touched.
  173.  
  174.                DBE adds no new events.  DBE does not extend the
  175.                semantics of any existing events with the exception of
  176.                adding a new drawable type called _X_d_b_e_B_a_c_k_B_u_f_f_e_r.
  177.  
  178.                If events, replies, or errors that contain a drawable
  179.                (e.g., GraphicsExpose) are generated in response to a
  180.                request, the drawable returned will be the one
  181.                specified in the request.
  182.  
  183.                DBE advertises which visuals support double buffering.
  184.  
  185.                DBE does not include any timing or synchronization
  186.                facilities.  Applications that need such facilities
  187.                (e.g., to maintain a constant frame rate) should
  188.                investigate the Synchronization Extension, an X
  189.                Consortium standard.
  190.  
  191.           WWWWiiiinnnnddddoooowwww MMMMaaaannnnaaaaggggeeeemmmmeeeennnntttt OOOOppppeeeerrrraaaattttiiiioooonnnnssss
  192.  
  193.  
  194.  
  195.      Page 3                                           (printed 4/6/01)
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.      DDDDBBBBEEEE((((3333XXXX11111111))))          XXXX VVVVeeeerrrrssssiiiioooonnnn 11111111 ((((RRRReeeelllleeeeaaaasssseeee 6666....3333))))           DDDDBBBBEEEE((((3333XXXX11111111))))
  203.  
  204.  
  205.  
  206.                The basic philosophy of DBE is that both buffers are
  207.                treated the same by X window management operations.
  208.  
  209.                When a double-buffered window is destroyed, both
  210.                buffers associated with the window are destroyed, and
  211.                all back buffer names associated with the window are
  212.                freed.
  213.  
  214.                If the size of a double-buffered window changes, both
  215.                buffers assume the new size.  If the window's size
  216.                increases, the effect on the buffers depends on whether
  217.                the implementation honors bit gravity for buffers.  If
  218.                bit gravity is implemented, then the contents of both
  219.                buffers are moved in accordance with the window's bit
  220.                gravity, and the remaining areas are tiled with the
  221.                window background.  If bit gravity is not implemented,
  222.                then the entire unobscured region of both buffers is
  223.                tiled with the window background.  In either case,
  224.                Expose events are generated for the region that is
  225.                tiled with the window background.
  226.  
  227.                If the XXXXGGGGeeeettttGGGGeeeeoooommmmeeeettttrrrryyyy(((()))) function is executed on an
  228.                _X_d_b_e_B_a_c_k_B_u_f_f_e_r, the returned x, y, and border-width
  229.                will be zero.
  230.  
  231.                If the Shape extension SSSShhhhaaaappppeeeeRRRReeeeccccttttaaaannnngggglllleeeessss,,,, SSSShhhhaaaappppeeeeMMMMaaaasssskkkk,,,,
  232.                SSSShhhhaaaappppeeeeCCCCoooommmmbbbbiiiinnnneeee,,,, or SSSShhhhaaaappppeeeeOOOOffffffffsssseeeetttt request is executed on a
  233.                double-buffered window, both buffers are reshaped to
  234.                match the new window shape.  The region difference D =
  235.                new shape - old shape is tiled with the window
  236.                background in both buffers, and Expose events are
  237.                generated for D.
  238.  
  239.           CCCCoooommmmpppplllleeeexxxx SSSSwwwwaaaapppp AAAAccccttttiiiioooonnnnssss
  240.  
  241.                DBE has no explicit knowledge of ancillary buffers
  242.                (e.g. depth buffers or alpha buffers), and only has a
  243.                limited set of defined swap actions.  Some applications
  244.                may need a richer set of swap actions than DBE
  245.                provides.  Some DBE implementations have knowledge of
  246.                ancillary buffers, and/or can provide a rich set of
  247.                swap actions. Instead of continually extending DBE to
  248.                increase its set of swap actions, DBE provides a
  249.                flexible "idiom" mechanism.  If an applications's needs
  250.                are served by the defined swap actions, it should use
  251.                them; otherwise, it should use the following method of
  252.                expressing a complex swap action as an idiom.
  253.                Following this policy will ensure the best possible
  254.                performance across a wide variety of implementations.
  255.  
  256.                As suggested by the term "idiom," a complex swap action
  257.                should be expressed as a group/series of requests.
  258.  
  259.  
  260.  
  261.      Page 4                                           (printed 4/6/01)
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.      DDDDBBBBEEEE((((3333XXXX11111111))))          XXXX VVVVeeeerrrrssssiiiioooonnnn 11111111 ((((RRRReeeelllleeeeaaaasssseeee 6666....3333))))           DDDDBBBBEEEE((((3333XXXX11111111))))
  269.  
  270.  
  271.  
  272.                Taken together, this group of requests may be combined
  273.                into an atomic operation by the implementation, in
  274.                order to maximize performance.  The set of idioms
  275.                actually recognized for optimization is implementation
  276.                dependent.  To help with idiom expression and
  277.                interpretation, an idiom must be surrounded by two
  278.                function calls: XXXXddddbbbbeeeeBBBBeeeeggggiiiinnnnIIIIddddiiiioooommmm(((()))) and XXXXddddbbbbeeeeEEEEnnnnddddIIIIddddiiiioooommmm(((())))....
  279.                Unless this begin-end pair surrounds the idiom, it may
  280.                not be recognized by a given implementation, and
  281.                performance will suffer.
  282.  
  283.                For example, if an application wants to swap buffers
  284.                for two windows, and use X to clear only certain planes
  285.                of the back buffers, the application would make the
  286.                following calls as a group, and in the following order:
  287.  
  288.                     XXXXddddbbbbeeeeBBBBeeeeggggiiiinnnnIIIIddddiiiioooommmm(((())))....
  289.  
  290.                     XXXXddddbbbbeeeeSSSSwwwwaaaappppBBBBuuuuffffffffeeeerrrrssss(((()))) with XIDs for two windows, each
  291.                     of which uses a swap action of Untouched.
  292.  
  293.                     XXXXFFFFiiiillllllllRRRReeeeccccttttaaaannnngggglllleeee(((()))) to the back buffer of one window.
  294.  
  295.                     XXXXFFFFiiiillllllllRRRReeeeccccttttaaaannnngggglllleeee(((()))) to the back buffer of the other
  296.                     window.
  297.  
  298.                     XXXXddddbbbbeeeeEEEEnnnnddddIIIIddddiiiioooommmm(((())))....
  299.  
  300.                The XXXXddddbbbbeeeeBBBBeeeeggggiiiinnnnIIIIddddiiiioooommmm(((()))) and XXXXddddbbbbeeeeEEEEnnnnddddIIIIddddiiiioooommmm(((()))) functions do
  301.                not perform any actions themselves.  They are treated
  302.                as markers by implementations that can combine certain
  303.                groups/series of requests as idioms, and are ignored by
  304.                other implementations or for non-recognized
  305.                groups/series of requests.  If these function calls are
  306.                made out of order, or are mismatched, no errors are
  307.                sent, and the functions are executed as usual, though
  308.                performance may suffer.
  309.  
  310.                XXXXddddbbbbeeeeSSSSwwwwaaaappppBBBBuuuuffffffffeeeerrrrssss(((()))) need not be included in an idiom.
  311.                For example, if a swap action of Copied is desired, but
  312.                only some of the planes should be copied, XXXXCCCCooooppppyyyyAAAArrrreeeeaaaa(((())))
  313.                may be used instead of XXXXddddbbbbeeeeSSSSwwwwaaaappppBBBBuuuuffffffffeeeerrrrssss(((()))).... If
  314.                XXXXddddbbbbeeeeSSSSwwwwaaaappppBBBBuuuuffffffffeeeerrrrssss(((()))) is included in an idiom, it should
  315.                immediately follow the XXXXddddbbbbeeeeBBBBeeeeggggiiiinnnnIIIIddddiiiioooommmm(((()))) call.  Also,
  316.                when the XXXXddddbbbbeeeeSSSSwwwwaaaappppBBBBuuuuffffffffeeeerrrrssss(((()))) is included in an idiom,
  317.                that request's swap action will still be valid, and if
  318.                the swap action might overlap with another request,
  319.                then the final result of the idiom must be as if the
  320.                separate requests were executed serially.  For example,
  321.                if the specified swap action is Untouched, and if a
  322.                XXXXFFFFiiiillllllllRRRReeeeccccttttaaaannnngggglllleeee(((()))) using a client clip rectangle is done
  323.                to the window's back buffer after the XXXXddddbbbbeeeeSSSSwwwwaaaappppBBBBuuuuffffffffeeeerrrrssss(((())))
  324.  
  325.  
  326.  
  327.      Page 5                                           (printed 4/6/01)
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.      DDDDBBBBEEEE((((3333XXXX11111111))))          XXXX VVVVeeeerrrrssssiiiioooonnnn 11111111 ((((RRRReeeelllleeeeaaaasssseeee 6666....3333))))           DDDDBBBBEEEE((((3333XXXX11111111))))
  335.  
  336.  
  337.  
  338.                call, then the contents of the new back buffer (after
  339.                the idiom) will be the same as if the idiom was not
  340.                recognized by the implementation.
  341.  
  342.                It is highly recommended that API providers define, and
  343.                application developers use, "convenience" functions
  344.                that allow client applications to call one procedure
  345.                that encapsulates common idioms.  These functions will
  346.                generate the XXXXddddbbbbeeeeBBBBeeeeggggiiiinnnnIIIIddddiiiioooommmm(((()))),,,, idiom, and
  347.                XXXXddddbbbbeeeeEEEEnnnnddddIIIIddddiiiioooommmm(((()))) calls.  Usage of these functions will
  348.                ensure best possible performance across a wide variety
  349.                of implementations.
  350.  
  351.      SSSSEEEEEEEE AAAALLLLSSSSOOOO
  352.           _X_d_b_e_A_l_l_o_c_a_t_e_B_a_c_k_B_u_f_f_e_r_N_a_m_e(), _X_d_b_e_B_e_g_i_n_I_d_i_o_m(),
  353.           _X_d_b_e_D_e_a_l_l_o_c_a_t_e_B_a_c_k_B_u_f_f_e_r_N_a_m_e(), _X_d_b_e_E_n_d_I_d_i_o_m(),
  354.           _X_d_b_e_F_r_e_e_V_i_s_u_a_l_I_n_f_o(), _X_d_b_e_G_e_t_B_a_c_k_B_u_f_f_e_r_A_t_t_r_i_b_u_t_e_s(),
  355.           _X_d_b_e_G_e_t_V_i_s_u_a_l_I_n_f_o(), _X_d_b_e_Q_u_e_r_y_E_x_t_e_n_s_i_o_n(),
  356.           _X_d_b_e_S_w_a_p_B_u_f_f_e_r_s().
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.      Page 6                                           (printed 4/6/01)
  394.  
  395.  
  396.  
  397.